#!/bin/bash
if [ ! -s isexp ]; then
mkdir isexp
fi

cd isexp
if [ ! -s /usr/local/lib/libtfm.a ] ; then
	rm -rf tomsfastmath
	git clone -b develop https://gitee.com/fotg/tomsfastmath
	cd tomsfastmath
	sudo make install
	cd ..
fi

if [ ! -s /usr/local/lib/libtomcrypt.a ]; then
	rm -rf libtomcrypt
	git clone -b develop https://gitee.com/fotg/libtomcrypt
	cd libtomcrypt
	sudo make install CFLAGS="-DTFM_DESC"
	cd ..
fi

if [ ! -s isecure ]; then
	git clone https://gitee.com/fotg/isecure
else
	cd isecure
	for file in exp1 exp2 exp1/test1.c exp1/Makefile exp1/run.sh exp2/test2.c exp2/Makefile exp2/run.sh; do
		if [ ! -s $file ]; then
		cd ..
		rm -rf isecure
		git clone https://gitee.com/fotg/isecure
		break
		fi
	done
	cd ..
fi

cd isecure/exp1
chmod +x run.sh
make test
cd ../exp2
chmod +x run.sh
make test